//
//  MassNameViewController.m
//  毕业设计
//
//  Created by 龙波 on 2017/8/21.
//  Copyright © 2017年 吴添培. All rights reserved.
//

#import "MassNameViewController.h"
#import "MassTextController.h"

#define kArraycout 9
@interface MassNameViewController ()
@property(nonatomic,strong) NSArray *testArray;

@end

@implementation MassNameViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self initUI];
    [self setupNav];
    UIButton *testBtn = [[UIButton alloc]initWithFrame:CGRectMake(49, 49, 32, 45)];
    testBtn.backgroundColor = [UIColor redColor];
   // [self.view addSubview:testBtn];
    self.testArray = [NSArray arrayWithObjects:@"wendy",@"andy",@"tom",@"jonery",@"stany", nil];

    
}

- (void)setupNav
{
    self.navigationItem.title = @"所有社团";
}



- (void)initUI{
    
    for (int i = 0; i < kArraycout; ++i) {
        
        int x = i%2;
        int y = i/2;
        //背景
        UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(x*(SCREENWIDTH-15)/2+5*(x+1), y*125+25, (SCREENWIDTH-15)/2, 120)];
        backView.backgroundColor = [UIColor redColor];
        backView.tag = 10+i;
//        backView.hidden = YES;
        [self.view addSubview:backView];
        //
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(OnTapBackView:)];
        [backView addGestureRecognizer:tap];
        
        //图
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, backView.frame.size.width, backView.frame.size.height-40)];
        imageView.tag = 50+i;
        imageView.contentMode = UIViewContentModeScaleAspectFit;
        imageView.image = [UIImage imageNamed:@"199cc000bec0993d816d01b0c0c7ce26"];
        
        [backView addSubview:imageView];
        
        //标题
        UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(imageView.frame), backView.frame.size.width, 30)];
        titleLabel.font = [UIFont systemFontOfSize:15];
        titleLabel.textAlignment = NSTextAlignmentCenter;
        titleLabel.textColor = [UIColor whiteColor];
        titleLabel.text = @"社团名字";
        titleLabel.tag = 100+i;
        [backView addSubview:titleLabel];
    }
    

}

- (void)OnTapBackView:(UITapGestureRecognizer *)sender{
   NSLog(@"第·%ld", (long)sender.view.tag);
    MassTextController *massView = [[MassTextController alloc]initWithFrame:self.view.frame WithArray:self.testArray];
    NSLog(@"%@",self.testArray);
    [self.navigationController pushViewController:massView animated:YES];
    
}

@end
